package com.sk.sourcecircle.activity.mine.act;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.widget.ImageView;

import com.sk.sourcecircle.R;
import com.sk.sourcecircle.activity.mine.fragment.AllOrderFragment;
import com.sk.sourcecircle.activity.mine.fragment.AlreadyCancelFragment;
import com.sk.sourcecircle.activity.mine.fragment.AlreadyFinshFragment;
import com.sk.sourcecircle.activity.mine.fragment.NotFinishOrderFragment;
import com.sk.sourcecircle.adapter.MyPagerAdapter;
import com.sk.sourcecircle.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by sk on 2017/11/23.
 */

public class MyOrderActivity extends BaseActivity {
    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.my_table)
    TabLayout myTable;
    @BindView(R.id.my_pager)
    ViewPager myPager;

    AllOrderFragment allOrderFragment;
    NotFinishOrderFragment notFinishOrderFragment;
    AlreadyFinshFragment alreadyFinshFragment;
    AlreadyCancelFragment alreadyCancelFragment;
    private List<Fragment> fragmentList = new ArrayList<>();

    @Override
    protected int getContentView() {
        return R.layout.activity_my_order;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initFragments();

    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    private void initFragments(){

        allOrderFragment = new AllOrderFragment();
        notFinishOrderFragment = new NotFinishOrderFragment();
        alreadyFinshFragment = new AlreadyFinshFragment();
        alreadyCancelFragment = new AlreadyCancelFragment();

        fragmentList.add(allOrderFragment);
        fragmentList.add(notFinishOrderFragment);
        fragmentList.add(alreadyFinshFragment);
        fragmentList.add(alreadyCancelFragment);

        myPager.setOffscreenPageLimit(4);

        MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager(), getResources().getStringArray(R.array.order_array), fragmentList);
        myPager.setAdapter(adapter);
        myTable.setupWithViewPager(myPager);
    }


    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }
}
